package test1;

import java.util.Arrays;

public class Test1 {
    public static void main(String[] args) {
        int[] nums = new int[]{1, 5, 2, 5, 2, 5, 3, 4, 8, 9};
        int[] arr = bubble_sort(nums);
        for (int i : arr) {
            System.out.print(i + " ");
        }
    }

    public static int[] bubble_sort(int[] nums) {
        int[] arr = Arrays.copyOf(nums, nums.length);
        for (int i = 0; i < arr.length - 1; i++) {
            boolean flag = true;
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                    flag = false;
                }
            }
        }
        return arr;
    }
}
